<template>
  <div>
    <table>
      <mgl v-for="(val, index) in goodsArr" :key="index" :arr="val"></mgl>
    </table>
    <p>All Number:{{sum}}</p>
  </div>
</template>

<script>
import mgl from "./components/mgl";
export default {
  components: {
    mgl,
  },
  data() {
    return {
      goodsArr: [
        {
          count: 0,
          goodsName: "Watermelon",
        },
        {
          count: 0,
          goodsName: "Banana",
        },
        {
          count: 0,
          goodsName: "Orange",
        },
        {
          count: 0,
          goodsName: "Pineapple",
        },
        {
          count: 0,
          goodsName: "Strawberry",
        },
      ],
    };
  },
  computed: {
    sum() {
      return this.goodsArr.reduce((sum, obj) => (sum += obj.count * 1), 0);
    },
  },
};
</script>

<style>
</style>